function K = buildK(x)
    n = size(x, 2);
    K = zeros(n);
    for i = 1:n - 1
        K = assemble(K, i, x(i), x(i + 1));
    end
end